<template>
  <view class='container'>
    <view class="title sticky-tabs">{{obj.assetsName}}————转移申请</view>
    <u-gap height="10" bgColor="#f5f5f5"></u-gap>
    <view>
      <u-cell-group>
        <u-cell title="资产名称" :value="obj.assetsName"></u-cell>
        <u-cell title="资产大类" :value="obj.assetsClass"></u-cell>
        <u-cell title="资产小类" :value="obj.assetsSubclass"></u-cell>
        <u-cell title="原使用人" :value="obj.user"></u-cell>
        <u-cell title="被转移人" isLink @click="selectHanlder">
          <text slot="value" class="u-slot-value">{{formStata.divertUserName}}</text>
        </u-cell>
        <u-cell title="备注">
          <view slot="value" style="width: 50%;">
            <u-input v-model="formStata.remarks" border="none" placeholder="请输入" inputAlign="right">
            </u-input>
          </view>
        </u-cell>
      </u-cell-group>
    </view>
    <view class="btn">
      <view class="exit" @click="exit">取消</view>
      <view class="save" @click="submit">保存</view>
    </view>
    <!-- 基础用法选人 -->
    <u-popup height="90%" mode="bottom" :show="show">
      <tree @onchange="onchange"></tree>
    </u-popup>
  </view>
</template>

<script>
import tree from "@/components/search/tree/tree.vue"

export default {
  components: {
    tree
  },
  data() {
    return {
      obj: {},
      show: false,
      formStata: {
        divertUser: '',
        divertUserName: '',
        remarks: '',
        assetsID: '',
        isRetire: false,
        isCross: false,
        exUser: '',
        exUserName: ''
      }
    };
  },
  onLoad(e) {
    this.$u.api.GetDetils({ objectID: e.id }).then(res => {
      this.obj = res.data
      this.formStata.assetsID = res.data.objectID
    })
  },

  methods: {
    // 打开选人
    selectHanlder() {
      this.show = true
    },
    onchange(kk, user, val) {
      this.show = false
      this.formStata.divertUser = val.userId
      this.formStata.divertUserName = user
    },
    exit() {
      uni.navigateBack();
    },
    submit() {
      var _this = this
      wx.showModal({
        title: '提示',
        content: '是否确认提交？',
        success(v) {
          _this.$u.api.NewApply(_this.formStata).then(res => {
            if (res.flag) {
              _this.$u.toast('提交成功');

            }
          })
        }
      })
    }
  }
};
</script>

<style scoped lang="scss">
.container {
  min-height: 100vh;
  background: #fff;
  padding-bottom: 180rpx;
  .title {
    height: 100rpx;
    line-height: 100rpx;
    font-size: 34rpx;
    text-align: center;
  }
  .deposit {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    .deposit-btn {
      width: 100rpx;
      margin-left: 10rpx;
    }
  }
  .btn {
    font-size: 30rpx;
    display: flex;
    justify-content: space-around;
    background: #f5f5f5;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 30rpx 0;

    .exit {
      width: 335rpx;
      height: 88rpx;
      background-color: #ffffff;
      border-radius: 10rpx;
      color: #666666;
      text-align: center;
      line-height: 88rpx;
    }
    .save {
      width: 335rpx;
      height: 88rpx;
      background-color: #0d6fb8;
      border-radius: 10rpx;
      color: #ffffff;
      text-align: center;
      line-height: 88rpx;
    }
  }
}
.sticky-tabs {
  z-index: 990;
  position: sticky;
  top: var(--window-top);
  background-color: #fff;
}
</style>
